//
//  LSTabbar.m
//  HaoShiHuo
//
//  Created by apple on 14/11/17.
//  Copyright (c) 2014年 paris. All rights reserved.
//

#import "LSTabbar.h"

@implementation LSTabbar

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (instancetype)initWithMainTabbar:(CGRect )frame block:(seleteTabbar)sender
{
    self = [super init];
    if (self) {
        self = [[NSBundle mainBundle]loadNibNamed:@"LSTabbar" owner:nil options:nil][0];
        [self setBackgroundColor:[UIColor clearColor]];
        self.selSender = sender;
        //[self.labelLine setFrame:CGRectMake(0, 0, 320, 0.5)];
        [self initColors];
    }
    return self;
}

- (void)initColors
{
    for (UIButton *sen in self.bottomButtons) {
        
        //这块可以设置tabBar上button的所有的字体颜色和字体大小
        
        
        //可以根据 当前屏幕算 或者屏幕的尺寸 算比例就行了
        
        //[sen .imageView.image imageWithAlignmentRectInsets:UIEdgeInsetsMake(<#CGFloat top#>, <#CGFloat left#>, <#CGFloat bottom#>, <#CGFloat right#>)]
        
        //[sen .titleLabel setLayoutMargins:UIEdgeInsetsMake(<#CGFloat top#>, <#CGFloat left#>, <#CGFloat bottom#>, <#CGFloat right#>)]
        
        
        NSDictionary* selectedTextAttributes = @{NSFontAttributeName:[UIFont boldSystemFontOfSize:16],
                                                NSForegroundColorAttributeName: [UIColor colorWithHexString:@"0086D7"]};
        
        NSAttributedString *selectAttr=[[NSAttributedString alloc]initWithString:sen.titleLabel.text attributes:selectedTextAttributes];
        
        [sen setAttributedTitle:selectAttr forState:UIControlStateSelected];
        [sen setAttributedTitle:selectAttr forState:UIControlStateHighlighted];
        
        
        
  
      
        
        NSDictionary* unselectedTextAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:16],
                                                   NSForegroundColorAttributeName: [UIColor colorWithHexString:@"B0B0B0"]};
        
        NSAttributedString *normalAttr=[[NSAttributedString alloc]initWithString:sen.titleLabel.text attributes:unselectedTextAttributes];
        
         [sen setAttributedTitle: normalAttr forState:UIControlStateNormal];
    }
    
    //可以从这里配置uibutton里面图片和文字的偏移量
    

   // [self.buttonCard setTitleColor:UIColorFromRGB(0x999999) forState:UIControlStateSelected];
}



- (IBAction)seleteClick:(UIButton *)sender
{
    self.selSender(sender);
}
@end
